package com.ruoyi.oa.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.oa.domain.OaConfirmLogs;
import com.ruoyi.oa.service.IOaConfirmLogsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 审核日志Controller
 * 
 * @author ruoyi
 * @date 2021-10-31
 */
@RestController
@RequestMapping("/confirmLogs")
public class OaConfirmLogsController extends BaseController
{
    @Autowired
    private IOaConfirmLogsService oaConfirmLogsService;

    /**
     * 查询审核日志列表
     */
    @PreAuthorize(hasPermi = "oa:confirmLogs:list")
    @GetMapping("/list")
    public TableDataInfo list(OaConfirmLogs oaConfirmLogs)
    {
        startPage();
        List<OaConfirmLogs> list = oaConfirmLogsService.selectOaConfirmLogsList(oaConfirmLogs);
        return getDataTable(list);
    }

    /**
     * 导出审核日志列表
     */
    @PreAuthorize(hasPermi = "oa:confirmLogs:export")
    @Log(title = "审核日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaConfirmLogs oaConfirmLogs) throws IOException
    {
        List<OaConfirmLogs> list = oaConfirmLogsService.selectOaConfirmLogsList(oaConfirmLogs);
        ExcelUtil<OaConfirmLogs> util = new ExcelUtil<OaConfirmLogs>(OaConfirmLogs.class);
        util.exportExcel(response, list, "审核日志数据");
    }

    /**
     * 获取审核日志详细信息
     */
    @PreAuthorize(hasPermi = "oa:confirmLogs:query")
    @GetMapping(value = "/{confirmLogUuid}")
    public AjaxResult getInfo(@PathVariable("confirmLogUuid") String confirmLogUuid)
    {
        return AjaxResult.success(oaConfirmLogsService.selectOaConfirmLogsByConfirmLogUuid(confirmLogUuid));
    }

    /**
     * 新增审核日志
     */
    @PreAuthorize(hasPermi = "oa:confirmLogs:add")
    @Log(title = "审核日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaConfirmLogs oaConfirmLogs)
    {
        return toAjax(oaConfirmLogsService.insertOaConfirmLogs(oaConfirmLogs));
    }

    /**
     * 修改审核日志
     */
    @PreAuthorize(hasPermi = "oa:confirmLogs:edit")
    @Log(title = "审核日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaConfirmLogs oaConfirmLogs)
    {
        return toAjax(oaConfirmLogsService.updateOaConfirmLogs(oaConfirmLogs));
    }

    /**
     * 删除审核日志
     */
    @PreAuthorize(hasPermi = "oa:confirmLogs:remove")
    @Log(title = "审核日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{confirmLogUuids}")
    public AjaxResult remove(@PathVariable String[] confirmLogUuids)
    {
        return toAjax(oaConfirmLogsService.deleteOaConfirmLogsByConfirmLogUuids(confirmLogUuids));
    }
}
